/*
 JETI_EX_SENSOR.h, Version 0.1
 Mars 2012, by Denis Artru
 alarm and jetibox display are based on work of Uwe Gartmann and Alexander Buschek
 written for Arduino MEGA using rx2/tx2
*/

#ifndef JETI_EX_SENSOR_h
#define JETI_EX_SENSOR_h
#include <inttypes.h>
#include <arduino.h>

#define JETI_SENSOR_ID1 0xB3
#define JETI_SENSOR_ID2 0x55
#define JETI_SENSOR_ID3 0xA8
#define JETI_SENSOR_ID4 0x55

#define LCDMaxPos 32

#define JB_key_none     0b0000
#define JB_key_up       0b0010
#define JB_key_right    0b0001
#define JB_key_down     0b0100
#define JB_key_left     0b1000

class JETI_Box_class {
private:
	int nbValueEX;
	char* nameEX[0x0F];
	char* unitEX[0x0F];
	uint8_t precisionEX[0x0F]; /* 0 int; 1,2,3 float; 4 date, 5 time, 6 GPS*/
	int* valueEX[0x0F];
	char alarmEX;
	uint8_t trameCmpt;
	uint8_t valueEXToSend;
	uint8_t attente;
public:
	volatile uint8_t frame[0xFF];
	volatile bool bit9[0xFF];
	volatile uint8_t frameSize;
   JETI_Box_class();
   void UartInit(const char* sensorName);
	uint8_t addData(const char* name, char* unit);
	void setValue(uint8_t ident, short* valuePtr);
	void setValue(uint8_t ident, float* valuePtr, uint8_t precision);
	void setValueTime(uint8_t ident, uint8_t[3]);
	void setValueDate(uint8_t ident, uint8_t[3]);
	void setValueGPS(uint8_t ident, uint8_t[4]); /* [0] NESW , [1] angle, [2][3] minute/1000*/
	void unsetValue(uint8_t ident);
   void JetiBox(const char* line1, const char* line2);
	bool createFrame();
	void alarm(char alarmLetter);
   uint8_t readbuttons();
};

extern volatile uint8_t JetiFrameState;
extern JETI_Box_class JB;

#endif
